from MFNnetwork import *
import sys

def read_data(filename):
    f = open(filename, "r")
    data = []
    for line in f:
        # filter the newline character
        while line[-1] == '\r' or line[-1] == '\n':
            line = line[:-1]
        data.append(line.split(","))
    # convert string to integer
    for i in range(len(data)):
        for j in range(len(data[i])):
                data[i][j] = int(data[i][j])
    return data

def main():
    training_data = read_data(sys.argv[1])
    test_data = read_data(sys.argv[2])
    alpha = 0.78
    for i in range(50):
        print ("alpha:", alpha)
        network = back_prop_learning(training_data, Network([64, 32, 10]))
        test(test_data, network)
        print ("")

if __name__ == "__main__":
    main()
